#ifndef AREA_H
#define AREA_H

#include <QFrame>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QCursor>
#include <QByteArray>
#include <QColor>
#include <QScrollArea>

class Area : public QFrame
{
    Q_OBJECT

public:

   Area(QWidget* parent=0, int x=0, int y=0, int width=0, int height=0, int id=-1, int serial = 0);
   virtual ~Area() {}

   // setters
   void setColor(const QColor &);

   // getters
   int serial() const;
   int id() const;
   bool selected() const;

   virtual QByteArray contains() const = 0;
   virtual bool isEmpty() const = 0;

   void toGrid();
   void deSelect();
   void select();

   void emitDeselectOtherAreas();

private:

   void updateCursor( QMouseEvent * e );
   void stretch ( QMouseEvent * e );

   void mousePressEvent ( QMouseEvent * e );
   void mouseReleaseEvent ( QMouseEvent * );
   void mouseMoveEvent ( QMouseEvent * e );
   void enterEvent( QEvent * );
   void leaveEvent( QEvent * );

signals:

    void areaToBeMoved(int, int);
    void deselectOtherAreas(int);

protected:

   QColor _color;
   int _serial;
   bool _isResizable;

private:

   int _id;
   bool _moved;
   bool _selected;
   enum MouseAction {DRAG = 0, SUP = 1, SUPRIGHT = 2, SRIGHT = 3, SDOWNRIGHT = 4, SDOWN = 5} _mAct;
   QRect _lastGeometry;
   bool _mDown; // If mouse pressed?
   QPoint _dPos;

};

#endif // AREA_H
